import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/res/colors.dart';

import '../../viewmodel/iot/matress_detail_view_model.dart';

class MattressDetailPage extends BaseStatefulMvvmWidget {
  final String iotCode;
  final String title;

  MattressDetailPage({required this.iotCode, required this.title});

  @override
  State<StatefulWidget> createState() => _MattressDetailState();
}

class _MattressDetailState
    extends BaseMvvmRefreshState<MattressDetailViewModel, MattressDetailPage> {

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        iconTheme: IconThemeData(color: Colors.white),
        titleTextStyle: TextStyle(color: Colors.white,fontSize: 18),
        backgroundColor: Colours.purpleColor,
        elevation: 0,
      ),
      body: loadingContentWidget,
    );
  }

  @override
  MattressDetailViewModel createViewModel() {
    return MattressDetailViewModel(context, iotCode: widget.iotCode);
  }

  @override
  void onRetryClick() {
    viewModel.requestRefresh(showAni: false);
  }

  @override
  Widget createScrollWidget() {
    return ListView(
      children: [
        viewModel.topContent(),
        viewModel.heartChart(),
        viewModel.breathChart(),
      ],
    );
  }
}
